import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'dialog_data.dart';

class JRDialogWithType1 extends StatelessWidget {
  final TextWithHorizontalBtnDialogData data;

  const JRDialogWithType1({Key? key, required this.data}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(16.w),
      ),
      width: 280.w,
      padding: EdgeInsets.symmetric(horizontal: 24.w),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          SizedBox(
            height: 24.h,
          ),
          Text(
            data.title,
            textAlign: TextAlign.center,
            style: TextStyle(
              fontSize: 16.sp,
              fontWeight: FontWeight.w600,
              color: Color(0xff333333),
              height: 18 / 18,
            ),
          ),
          SizedBox(
            height: 12.h,
          ),
          Text(
            data.desc,
            textAlign: TextAlign.center,
            style: TextStyle(
              fontSize: 13.sp,
              fontWeight: FontWeight.w400,
              color: Color(0xff666666),
              height: 22 / 14,
            ),
          ),
          SizedBox(
            height: 24.h,
          ),
          Row(
            children: [
              Expanded(
                  child: CupertinoButton(
                    onPressed: () async{
                      if ((await data.onLeftBtnPress?.call()) ?? true) {
                    Navigator.pop(context,false);
                  }
                },
                minSize: 0,
                padding: EdgeInsets.zero,
                child: Container(
                  height: 40.h,
                  decoration: const ShapeDecoration(
                    color: Color(0xfff6f7f9),
                    shape: StadiumBorder()
                  ),
                  alignment: Alignment.center,
                  child: Text(
                    data.leftBtnText,
                    style: TextStyle(
                      fontSize: 16.sp,
                      color: Color(0xff666666),
                      height: 15 / 15,
                    ),
                  ),
                ),
              )),
              SizedBox(
                width: 12.w,
              ),
              Expanded(
                  child: CupertinoButton(
                    onPressed: () async{
                      if ((await data.onRightBtnPress?.call()) ?? true) {
                    Navigator.pop(context,true);
                  }
                },
                minSize: 0,
                padding: EdgeInsets.zero,
                child: Container(
                  height: 40.h,
                  decoration: const ShapeDecoration(
                    color: Color(0xffffd400),
                    shape: StadiumBorder(),
                  ),
                  alignment: Alignment.center,
                  child: Text(
                    data.rightBtnText,
                    style: TextStyle(
                      fontSize: 16.sp,
                      color: Color(0xff333333),
                      height: 15 / 15,
                    ),
                  ),
                ),
              )),
            ],
          ),
          SizedBox(
            height: 24.h,
          ),
        ],
      ),
    );
  }
}
